******SET YOUR DIRECTORY to ...\replication



///////////////////////////////////////////////////////////////////////////////////////////
///Figure A.20
///////////////////////////////////////////////////////////////////////////////////////////
clear all
include discretiz.ado
cls

use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create outcome
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Create dependent variables
gen vc_pc=totnpcc_cc_offenses_vc*1000

gen ph10=ph1_plc_wtm_wtm_0_r*10 // Stata loops do not work well with decimals


discretiz ph10, range(60/80) interval(5(1)10) second depvar(perc_cc) endogenous(vc_pc) exogenous(i.year i.year#i.cdivcode) interact(tetra_corr) xt(fe) graph(coef)




///////////////////////////////////////////////////////////////////////////////////////////
///Table A.38///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear
drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Create standardized variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
egen cdivcodeyear=group(cdivcode year)
*Label variables
label var inter_goodtetra "Low LB x Lead"
label var vc_pc "Violent Crime"


***Non-parametric pH
ivreghdfe perc_cc (vc_pc = inter_goodtetra), abs(fipsplace_00 year cdivcode#year) 
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_nonparam, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, pH used, 6.8-7.7, F, `ff') slow(5000) replace
*Use bounds
ivreghdfe perc_cc (vc_pc = inter_tlXph_0_5* inter_tlXph_0_6* inter_tlXph_0_7* inter_tlXph_0_8*), abs(fipsplace_00 year cdivcode#year) 
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_nonparam, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, pH used, 0.5 bounds, F, `ff') slow(5000) 
*Use first polynomial
ivreghdfe perc_cc (vc_pc = c.tetra_corr#c.ph1_plc_wtm_wtm_0_r), abs(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_nonparam, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, pH used, 1st poly, F, `ff') slow(5000) 
*Use second polynomial
ivreghdfe perc_cc (vc_pc = c.tetra_corr#c.ph1_plc_wtm_wtm_0_r c.tetra_corr#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r), abs(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_nonparam, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, pH used, 2nd poly, F, `ff') slow(5000) 
*Use third polynomial
ivreghdfe perc_cc (vc_pc = c.tetra_corr#c.ph1_plc_wtm_wtm_0_r c.tetra_corr#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r c.tetra_corr#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r), abs(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_nonparam, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, pH used, 3rd poly, F, `ff') slow(5000) 
*Use fourth polynomial
ivreghdfe perc_cc (vc_pc = c.tetra_corr#c.ph1_plc_wtm_wtm_0_r c.tetra_corr#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r c.tetra_corr#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r c.tetra_corr#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r#c.ph1_plc_wtm_wtm_0_r), abs(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_nonparam, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, pH used, 4th poly, F, `ff') slow(5000) 



///////////////////////////////////////////////////////////////////////////////////////////
///Table A.39/////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear
drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g pop_msa = tot_ncc_oripop_corr + tot_cc_oripop_corr

*Create standardized variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
label var vc_pc "Violent crime"
egen cdivcodeyear=group(cdivcode year)

*Label variables
label var inter_goodtetra "Low LB x Lead"
label var inter_badtetra "High LB x Lead"

gen tetra_corr_19=tetra_corr
forvalues i=1/4{
local j=19+`i'
local l=19-`i'
gen tetra_corr_`j'=L`i'.tetra_corr
gen tetra_corr_`l'=F`i'.tetra_corr
}
gen inter_badtetra_15=(1-good_soil)*tetra_corr_15
ivreghdfe perc_cc (vc_pc = inter_badtetra_15), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
reghdfe vc_pc inter_badtetra_15 i.year, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local beta_gt=_b[inter_badtetra]
local se_gt=_se[inter_badtetra]
ivreghdfe perc_cc (vc_pc = inter_badtetra_15), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
outreg2 vc_pc using table_rob_laglead, tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, Year, 60-91, Estimation, IV, Lag lead, 15 years, F, `ff') adec(3) addstat(FS Beta, `beta_gt', FS s.e., `se_gt') slow(5000) replace
forvalues i=16/23{
gen inter_badtetra_`i'=(1-good_soil)*tetra_corr_`i'
ivreghdfe perc_cc (vc_pc = inter_badtetra_`i'), absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
reghdfe vc_pc inter_badtetra_`i', abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local beta_gt=_b[inter_badtetra]
local se_gt=_se[inter_badtetra]
ivreghdfe perc_cc (vc_pc = inter_badtetra_`i'),  abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
outreg2 vc_pc using table_rob_laglead, tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, Year, 60-91, Estimation, IV, Lag lead, `i' years, F, `ff') adec(3) addstat(FS Beta, `beta_gt', FS s.e., `se_gt') slow(5000) 
}





///////////////////////////////////////////////////////////////////////////////////////////
///FIGURE A.21 - TABLE A.40/////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////

clear all
import excel using "finaldata\tetraethyl_lead.xlsx", first
drop source Variable Note

drop if year == 1987

local lenght = 150
set obs `lenght'

****CREATING YEARS FROM 1987 to 2014
forval i =  47(1)74 {
	local y = 1986 + `i' - 46
	replace year = `y' in `i'
	replace tetraethyl = 0 in `i'
}
***** CREATING YEARS BEFORE 1941 (increase of 11580 a year in the first 3 years we observe)
forval i =  75(1)`lenght' {
	local y = 1941 - `i' + 74
	replace year = `y' in `i'
	local j = 1941 - `y'
	local imp_tetr = 48327 - (`j' * 11580)
	if `imp_tetr' > 0 {
		replace tetraethyl = `imp_tetr' in `i'
	}
	else {
		replace tetraethyl = 0 in `i'
	}
}
sort year

g tetra_agestructure = 0.02 * tetraethyl[_n-1] + 0.02 * tetraethyl[_n-2] + 0.02 * tetraethyl[_n-3] + 0.02 * tetraethyl[_n-4] + 0.02 * tetraethyl[_n-5] + 0.02 * tetraethyl[_n-6] + ///
	0.02 * tetraethyl[_n-7] + 0.02 * tetraethyl[_n-8] + 0.02 * tetraethyl[_n-9] + 0.02 * tetraethyl[_n-10] + 0.02 * tetraethyl[_n-11] + 0.02 * tetraethyl[_n-12] +  ///
	0.40 * tetraethyl[_n-13] + 0.04 * tetraethyl[_n-14] + ///
	0.72 * tetraethyl[_n-15] + ///
	0.90 * tetraethyl[_n-16] + ///
	0.97 * tetraethyl[_n-17] + ///
	1 * tetraethyl[_n-18] + ///
	0.88 * tetraethyl[_n-19] + ///
	0.80 * tetraethyl[_n-20] + ///
	0.76 * tetraethyl[_n-21] + ///
	0.72 * tetraethyl[_n-22] + ///
	0.68 * tetraethyl[_n-23] + ///
	0.64 * tetraethyl[_n-24] + ///
	0.58 * tetraethyl[_n-25] + 0.58 * tetraethyl[_n-26] + 0.58 * tetraethyl[_n-27] + 0.58 * tetraethyl[_n-28] + 0.58 * tetraethyl[_n-29] + ///
	0.44 * tetraethyl[_n-30] + 0.44 * tetraethyl[_n-31] + 0.44 * tetraethyl[_n-32] + 0.44 * tetraethyl[_n-33] + 0.44 * tetraethyl[_n-34] + ///
	0.31 * tetraethyl[_n-35] + 0.31 * tetraethyl[_n-36] + 0.31 * tetraethyl[_n-37] + 0.31 * tetraethyl[_n-38] + 0.31 * tetraethyl[_n-39] + ///
	0.20 * tetraethyl[_n-40] + 0.20 * tetraethyl[_n-41] + 0.20 * tetraethyl[_n-42] + 0.20 * tetraethyl[_n-43] + 0.20 * tetraethyl[_n-44] + ///
	0.13 * tetraethyl[_n-45] + 0.13 * tetraethyl[_n-46] + 0.13 * tetraethyl[_n-47] + 0.13 * tetraethyl[_n-48] + 0.13 * tetraethyl[_n-49] + ///
	0.08 * tetraethyl[_n-50] + 0.08 * tetraethyl[_n-51] + 0.08 * tetraethyl[_n-52] + 0.08 * tetraethyl[_n-53] + 0.08 * tetraethyl[_n-54] + ///
	0.06 * tetraethyl[_n-55] + 0.06 * tetraethyl[_n-56] + 0.06 * tetraethyl[_n-57] + 0.06 * tetraethyl[_n-58] + 0.06 * tetraethyl[_n-59] + ///
	0.04 * tetraethyl[_n-60] + 0.04 * tetraethyl[_n-61] + 0.04 * tetraethyl[_n-62] + 0.04 * tetraethyl[_n-63] + 0.04 * tetraethyl[_n-64] + ///
	0.01 * tetraethyl[_n-61] + 0.01 * tetraethyl[_n-62] + 0.01 * tetraethyl[_n-63] + 0.01 * tetraethyl[_n-64] + 0.01 * tetraethyl[_n-65] + 0.01 * tetraethyl[_n-66] + 0.01 * tetraethyl[_n-67] + 0.01 * tetraethyl[_n-68] + 0.01 * tetraethyl[_n-69] + 0.01 * tetraethyl[_n-70]

drop if year<1940

su tetra_agestructure, detail
replace tetra_agestructure = tetra_agestructure / r(max)

merge 1:n year using "finaldata\final_cc_data.dta"

drop if fipsplace_00==.
xtset fipsplace_00 year

label var tetra_agestructure "Past lead, weighted"
label var tetra_corr "Past lead, 19 years"
label var year "Year"

tsline tetra_agestructure tetra_corr if year>=1960
graph export ts_agestrlead.png, as(png) replace

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
gen inter_badtetra_agestr=(1-good_soil)*tetra_agestructure
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g pop_msa = tot_ncc_oripop_corr + tot_cc_oripop_corr

*Create standardized variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
g lnpop_cc = ln(tot_cc_oripop_corr)
g lnpop_ncc = ln(tot_ncc_oripop_corr)
gen lnpop_msa=ln(pop_msa)
egen cdivcodeyear=group(cdivcode year)

*Label variables
*label var inter_goodtetra_agestr "Low LB x Lead weighted"
label var inter_badtetra_agestr "High LB x Lead weighted"
label var vc_pc "Violent Crime"


*Regressions
***OLS
reghdfe perc_cc vc_pc, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
outreg2 vc_pc using table_agestructure, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, OLS, F, .)  replace
***First stage
reghdfe vc_pc inter_badtetra_agestr, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
outreg2 inter_badtetra using table_agestructure, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, OLS, F, .)
***IV
ivreghdfe perc_cc (vc_pc = inter_badtetra_agestr), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_agestructure, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, F, `ff')  
***RF
reghdfe perc_cc  inter_badtetra_agestr, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_agestructure, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, OLS, F, `ff')  
***IV CC
ivreghdfe lnpop_cc (vc_pc = inter_badtetra_agestr), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_agestructure, tex(frag) nocon noni nor2 nonotes label ctitle("ln(Pop CC)") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, F, `ff')  
***IV NCC
ivreghdfe lnpop_ncc (vc_pc = inter_badtetra_agestr), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_agestructure, tex(frag) nocon noni nor2 nonotes label ctitle("ln(Pop NCC)") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, F, `ff')  
***IV MSA
ivreghdfe lnpop_msa (vc_pc = inter_badtetra_agestr), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_agestructure, tex(frag) nocon noni nor2 nonotes label ctitle("ln(Pop MSA)") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, F, `ff') 




////////////////////////////////////////////////////////////////////////////////
///Table A.41
////////////////////////////////////////////////////////////////////////////////

use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g pop_msa = tot_ncc_oripop_corr + tot_cc_oripop_corr

*Create dependent variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
g lnpop_cc = ln(tot_cc_oripop_corr)
g lnpop_ncc = ln(tot_ncc_oripop_corr)
gen lnpop_msa=ln(pop_msa)

*Cluster variables
egen cdivcodeyear=group(cdivcode year)

*Label variables
label var vc_pc "Violent crime"
label var inter_badtetra "High LB x Lead"

gen inter_badtetra_stock=.
gen tetra_corr_stock=. 

forvalues i=1960/1991{
egen inter_badtetra_stock_`i'=total(inter_badtetra) if year<=`i' & year>=1960, by(fipsplace_00)
replace inter_badtetra_stock=inter_badtetra_stock_`i' if year==`i'
egen tetra_corr_stock_`i'=total(tetra_corr) if year<=`i' & year>=1960, by(year fipsplace_00)
replace tetra_corr_stock=tetra_corr_stock_`i' if year==`i'
drop inter_badtetra_stock_`i' tetra_corr_stock_`i'
}

gen inter_badtetra_lagstock=inter_badtetra*L.inter_badtetra_stock
label var inter_badtetra_lagstock "High LB x Lead x Stock(lag 1)"

reghdfe vc_pc inter_badtetra inter_badtetra_lagstock , abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
outreg2 vc_pc_stock using table_cumul, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, IV, Instrument, ., F, .)  replace
ivreghdfe perc_cc (vc_pc = inter_badtetra) , abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc_stock using table_cumul, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, IV, Instrument, Lag 0, F, `ff') 
ivreghdfe perc_cc (vc_pc = inter_badtetra inter_badtetra_lagstock) , abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc_stock using table_cumul, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, IV, Instrument, Lag 0 + Stock, F, `ff') 
forvalues i=1/10{
ivreghdfe perc_cc (vc_pc = inter_badtetra L(1/`i')inter_badtetra) , abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc_stock using table_cumul, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, IV, Instrument, Lags 0 to `i', F, `ff') 
}





///////////////////////////////////////////////////////////////////////////////////////////
///Table A.42
///////////////////////////////////////////////////////////////////////////////////////////

***Baum-snow data (taken from panel.do)
clear
set more off
set matsize 800

set mem 80m

** Create temp file with state-level hwy data for instrument **
use "finaldata\hwy-allyr-state.dta"

collapse (sum) lenc, by(year)

sort year

replace year=1900+year

gen sshrc = lenc/lenc[_N]
sort year

tempfile _temp
save `_temp'


*** Add on instrument to MSA - level data *********** 
use "finaldata\final_cc_data.dta", clear
*drop _merge

sort year
merge m:1 year using `_temp'
tab _merge
** Should be all 3
drop _merge

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g good_soil_ncc = (ph_ncc>=6.8 & ph_ncc<=7.7)
gen inter_badtetra_ncc=(1-good_soil_ncc)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g l10perc_cc = L10.perc_cc
gen l10inter_badtetra=L10.inter_badtetra

*Create per capita variables
gen vc_pc=totnpcc_cc_offenses_vc*1000

*Cluster variables
egen cdivcodeyear=group(cdivcode year)


*Generate 1960 variables
foreach var of varlist cpctblk pctblk{
gen `var'_1960_2=`var' if year==1960
egen `var'_1960=max(`var'_1960_2), by(FMSA)
drop `var'_1960_2
}
gen prop_black_1960=cpctblk_1960/pctblk_1960
g area_plc_sqkm=area_plc/1000000
g area_ncc_sqkm=area_ncc/1000000
gen pop_cc_1960_2=tot_cc_oripop_corr if year==1960
egen pop_cc_1960=max(pop_cc_1960_2), by(FMSA)
gen dens_cc_1960=pop_cc_1960/area_plc_sqkm
g dens_cc=tot_cc_oripop_corr/area_plc_sqkm
g dens_ncc=tot_ncc_oripop_corr/area_ncc_sqkm
egen rays_planc_1947=max(rays_planc), by(fipsplace_00)

replace dens_cc_1960 = dens_cc_1960 / 1000
*Create heterogeneities
*gen inter_rays_planc=inter_badtetra*rays_planc
gen inter_rays_planc_1947=inter_badtetra*rays_planc_1947
gen inter_dens_cc_1960=inter_badtetra*dens_cc_1960

*Label variables
*label var inter_rays_planc "High LB x Lead x Planned highways CC"
label var inter_rays_planc_1947 "High LB x Lead x Planned highways CC"
label var inter_dens_cc_1960 "High LB x Lead x Density CC 1960"
label var vc_pc "Violent Crime" 
label var inter_badtetra "High LB X Lead" 


***Interaction with highways CC
reghdfe vc_pc inter_badtetra inter_rays_planc_1947, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 inter_badtetra inter_rays_planc_1947 using table_het_densehigh, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, OLS, F, .)  replace

reghdfe perc_cc inter_badtetra inter_rays_planc_1947, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 inter_badtetra inter_rays_planc_1947 using table_het_densehigh, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, OLS, F, .)

ivreghdfe perc_cc (vc_pc = inter_badtetra inter_rays_planc_1947), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_het_densehigh, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, IV, F, `ff')


*****Interaction with  Density
reghdfe vc_pc inter_badtetra inter_dens_cc_1960, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 inter_badtetra inter_rays_planc_1947 using table_het_densehigh, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, OLS, F, .) 

reghdfe perc_cc inter_badtetra inter_dens_cc_1960, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 inter_badtetra inter_rays_planc_1947 using table_het_densehigh, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, OLS, F, .)

ivreghdfe perc_cc (vc_pc = inter_badtetra inter_dens_cc_1960), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_het_densehigh, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Estimation, IV, F, `ff') sortvar(inter_badtetra inter_rays_planc_1947 inter_dens_cc_1960 vc_pc)


///////////////////////////////////////////////////////////////////////////////////////////
///Table A.43
///////////////////////////////////////////////////////////////////////////////////////////
***Multiple places from UCR
use "finaldata\final_cc_data.dta", clear

merge m:1 FMSA using "finaldata\ucr_mismeas.dta"
drop if _merge==2
replace ori_multplc=0 if _merge==1
drop _merge

tab FMSAname if ori_multplc==1

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g pop_msa = tot_ncc_oripop_corr + tot_cc_oripop_corr

*Create dependent variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
g lnpop_cc = ln(tot_cc_oripop_corr)
g lnpop_ncc = ln(tot_ncc_oripop_corr)
gen lnpop_msa=ln(pop_msa)

*Cluster variables
egen cdivcodeyear=group(cdivcode year)

*Label variables
label var vc_pc "Violent crime"
label var inter_badtetra "High LB x Lead"

***IV
ivreghdfe perc_cc (vc_pc = inter_badtetra) if ori_multplc==0, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_baseline_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, NO, Missing, YES, Estimation, IV, F, `ff') replace 
***IV CC
ivreghdfe lnpop_cc (vc_pc = inter_badtetra) if ori_multplc==0 & perc_cc!=., abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_baseline_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("ln(Pop CC)") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, NO, Missing, YES, Estimation, IV, F, `ff')  
***IV NCC
ivreghdfe lnpop_ncc (vc_pc = inter_badtetra) if ori_multplc==0, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_baseline_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("ln(Pop NCC)") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, NO, Missing, YES, Estimation, IV, F, `ff')  

***Keep non-missing variables for CC
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
merge 1:1 fipsplace_00 year using "finaldata\ucr_nonmiss.dta"
drop if _merge==2
drop _merge

xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g pop_msa = tot_ncc_oripop_corr + tot_cc_oripop_corr

*Create dependent variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
g lnpop_cc = ln(tot_cc_oripop_corr)
g lnpop_ncc = ln(tot_ncc_oripop_corr)
gen lnpop_msa=ln(pop_msa)

*Cluster variables
egen cdivcodeyear=group(cdivcode year)

*Label variables
label var vc_pc "Violent crime"
label var inter_badtetra "High LB x Lead"

***IV
ivreghdfe perc_cc (vc_pc = inter_badtetra) if nonmissACT==12, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
*ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_baseline_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("Sh. Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, YES, Missing, NO, Estimation, IV, F, `ff')
***IV CC
ivreghdfe lnpop_cc (vc_pc = inter_badtetra) if nonmissACT==12 & perc_cc!=., abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_baseline_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("ln(Pop CC)") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, YES, Missing, NO, Estimation, IV, F, `ff')  
***IV NCC
ivreghdfe lnpop_ncc (vc_pc = inter_badtetra) if nonmissACT==12, abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_baseline_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("ln(Pop NCC)") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, YES, Missing, NO, Estimation, IV, F, `ff')  

///////////////////////////////////////////////////////////////////////////////////////////
///Table A.44
///////////////////////////////////////////////////////////////////////////////////////////
***Baum-snow data (taken from panel.do)
clear
set more off
set matsize 800

set mem 80m

** Create temp file with state-level hwy data for instrument **

use "finaldata\hwy-allyr-state.dta"

collapse (sum) lenc, by(year)

sort year

replace year=1900+year

gen sshrc = lenc/lenc[_N]
sort year

tempfile _temp
save `_temp'

***Multiple places from UCR
use "finaldata\final_cc_data.dta", clear

sort year
merge m:1 year using `_temp'
tab _merge
drop _merge

merge m:1 FMSA using "finaldata\ucr_mismeas.dta"
drop if _merge==2
replace ori_multplc=0 if _merge==1
drop _merge


drop if year>1991


g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
g good_soil_ncc = (ph_ncc>=6.8 & ph_ncc<=7.7)

*Cluster variables
egen cdivcodeyear=group(cdivcode year)

*Generate 1960 variables
foreach var of varlist cpctblk pctblk{
gen `var'_1960_2=`var' if year==1960
egen `var'_1960=max(`var'_1960_2), by(FMSA)
drop `var'_1960_2
}
gen prop_black_1960=cpctblk_1960/pctblk_1960
g area_plc_sqkm=area_plc/1000000
g area_ncc_sqkm=area_ncc/1000000
gen pop_cc_1960_2=tot_cc_oripop_corr if year==1960
egen pop_cc_1960=max(pop_cc_1960_2), by(FMSA)
gen dens_cc_1960=pop_cc_1960/area_plc_sqkm
g dens_cc=tot_cc_oripop_corr/area_plc_sqkm
g dens_ncc=tot_ncc_oripop_corr/area_ncc_sqkm
egen rays_planc_1947=max(rays_planc), by(fipsplace_00)




expand 2, gen(dup)

gen cc=(dup==1)

gen vc= totnpcc_ncc_offenses_vc*1000 if dup==0
replace vc=totnpcc_cc_offenses_vc*1000 if dup==1

gen id=fipsplace_00
replace id=fipsplace_00*1000  if dup==0

g highLB = (1-good_soil)  if dup==1
replace highLB = (1-good_soil_ncc) if dup==0

g ohighLB = (1-good_soil)  if dup==0
replace ohighLB = (1-good_soil_ncc) if dup==1


su tetra_corr, detail
g lead_n = (tetra_corr - r(min))/(1-r(min))

g leadXcc = cc * lead_n
g highLBXcc = cc * highLB
g highLBXlead = lead_n * highLB 
g ohighLBXlead = lead_n * ohighLB 

g leadXccXhighLB = lead_n * highLB * cc


label var cc "CC"
label var highLBXlead "High LB x Lead"
label var leadXccXhighLB "High LB x Lead x CC"
label var leadXcc "Lead x CC"


g inter_badtetra = (1-good_soil) * tetra_corr

*Create heterogeneities
gen inter_rays_planc=inter_badtetra*rays_planc
gen inter_rays_planc_1947=inter_badtetra*rays_planc_1947
gen inter_cpctblk_1960=inter_badtetra*cpctblk_1960
gen inter_prop_black_1960=inter_badtetra*prop_black_1960
g ldens = ln(dens_cc_1960)
su ldens if cc==1, detail
gen ldens_st = (ldens - r(mean))/r(sd)
gen ldens_p5 = ldens - r(p5)
gen inter_dens_cc_1960_st=inter_badtetra*ldens_st
gen inter_dens_cc_1960_p5=inter_badtetra*ldens_p5
gen inter_dens_cc_1960=inter_badtetra*ldens

*Label variables
label var inter_badtetra "High LB x Lead"
label var inter_cpctblk_1960 "High LB x Lead x Blacks CC 1960"
label var inter_prop_black_1960 "High LB x Lead x Blacks CC / MSA 1960"
label var inter_rays_planc "High LB x Lead x Planned highways CC"
label var inter_rays_planc_1947 "High LB x Lead x Planned highways CC"
label var inter_dens_cc_1960 "High LB x Lead x ln(Density CC 1960)"
label var inter_dens_cc_1960_p5 "High LB x Lead x ln(Density CC 1960)"
label var inter_dens_cc_1960_st "High LB x Lead x ln(Density CC 1960)"


reghdfe vc cc leadXcc highLBXlead leadXccXhighLB  if ori_multplc==0, absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear fipsplace_00)
outreg2 using table_vc_ccncc_rob_ucrmeas,  tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, NO, Missing, YES, Estimation, OLS) replace

g leadXhighway = tetra_corr * rays_planc_1947
g leadXdens = tetra_corr * ldens
g leadXdens_p5 = tetra_corr * ldens_p5
g leadXdens_st = tetra_corr * ldens_st
label var leadXhighway  "Lead x Planned highways CC"
label var leadXdens_st "Lead x ln(Density CC 1960)"
label var leadXdens_p5 "Lead x ln(Density CC 1960)"
label var leadXdens "Lead x ln(Density CC 1960)"



reghdfe vc highLBXlead leadXhighway inter_rays_planc_1947 if cc==1 & ori_multplc==0, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 using table_vc_ccncc_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, NO, Missing, YES, Estimation, OLS)

reghdfe vc highLBXlead leadXdens_p5 inter_dens_cc_1960_p5  if cc==1 & ori_multplc==0, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 using table_vc_ccncc_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, NO, Missing, YES, Estimation, OLS)


***Keep non-missing variables for CC
use "finaldata\final_cc_data.dta", clear

sort year
merge m:1 year using `_temp'
tab _merge
drop _merge

drop if fipsplace_00==.
merge 1:1 fipsplace_00 year using "finaldata\ucr_nonmiss.dta"
drop if _merge==2
drop _merge


drop if year>1991


g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
g good_soil_ncc = (ph_ncc>=6.8 & ph_ncc<=7.7)

*Cluster variables
egen cdivcodeyear=group(cdivcode year)

*Generate 1960 variables
foreach var of varlist cpctblk pctblk{
gen `var'_1960_2=`var' if year==1960
egen `var'_1960=max(`var'_1960_2), by(FMSA)
drop `var'_1960_2
}
gen prop_black_1960=cpctblk_1960/pctblk_1960
g area_plc_sqkm=area_plc/1000000
g area_ncc_sqkm=area_ncc/1000000
gen pop_cc_1960_2=tot_cc_oripop_corr if year==1960
egen pop_cc_1960=max(pop_cc_1960_2), by(FMSA)
gen dens_cc_1960=pop_cc_1960/area_plc_sqkm
g dens_cc=tot_cc_oripop_corr/area_plc_sqkm
g dens_ncc=tot_ncc_oripop_corr/area_ncc_sqkm
egen rays_planc_1947=max(rays_planc), by(fipsplace_00)




expand 2, gen(dup)

gen cc=(dup==1)

gen vc= totnpcc_ncc_offenses_vc*1000 if dup==0
replace vc=totnpcc_cc_offenses_vc*1000 if dup==1

gen id=fipsplace_00
replace id=fipsplace_00*1000  if dup==0

g highLB = (1-good_soil)  if dup==1
replace highLB = (1-good_soil_ncc) if dup==0

g ohighLB = (1-good_soil)  if dup==0
replace ohighLB = (1-good_soil_ncc) if dup==1


su tetra_corr, detail
g lead_n = (tetra_corr - r(min))/(1-r(min))

g leadXcc = cc * lead_n
g highLBXcc = cc * highLB
g highLBXlead = lead_n * highLB 
g ohighLBXlead = lead_n * ohighLB 

g leadXccXhighLB = lead_n * highLB * cc


label var cc "CC"
label var highLBXlead "High LB x Lead"
label var leadXccXhighLB "High LB x Lead x CC"
label var leadXcc "Lead x CC"


g inter_badtetra = (1-good_soil) * tetra_corr

*Create heterogeneities
gen inter_rays_planc=inter_badtetra*rays_planc
gen inter_rays_planc_1947=inter_badtetra*rays_planc_1947
gen inter_cpctblk_1960=inter_badtetra*cpctblk_1960
gen inter_prop_black_1960=inter_badtetra*prop_black_1960
g ldens = ln(dens_cc_1960)
su ldens if cc==1, detail
gen ldens_st = (ldens - r(mean))/r(sd)
gen ldens_p5 = ldens - r(p5)
gen inter_dens_cc_1960_st=inter_badtetra*ldens_st
gen inter_dens_cc_1960_p5=inter_badtetra*ldens_p5
gen inter_dens_cc_1960=inter_badtetra*ldens

*Label variables
label var inter_badtetra "High LB x Lead"
label var inter_cpctblk_1960 "High LB x Lead x Blacks CC 1960"
label var inter_prop_black_1960 "High LB x Lead x Blacks CC / MSA 1960"
label var inter_rays_planc "High LB x Lead x Planned highways CC"
label var inter_rays_planc_1947 "High LB x Lead x Planned highways CC"
label var inter_dens_cc_1960 "High LB x Lead x ln(Density CC 1960)"
label var inter_dens_cc_1960_p5 "High LB x Lead x ln(Density CC 1960)"
label var inter_dens_cc_1960_st "High LB x Lead x ln(Density CC 1960)"


reghdfe vc cc leadXcc highLBXlead leadXccXhighLB  if (cc==0 | cc==1 & nonmissACT==12), absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear fipsplace_00)
outreg2 using table_vc_ccncc_rob_ucrmeas,  tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, YES, Missing, NO, Estimation, OLS)


g leadXhighway = tetra_corr * rays_planc_1947
g leadXdens = tetra_corr * ldens
g leadXdens_p5 = tetra_corr * ldens_p5
g leadXdens_st = tetra_corr * ldens_st
label var leadXhighway  "Lead x Planned highways CC"
label var leadXdens_st "Lead x ln(Density CC 1960)"
label var leadXdens_p5 "Lead x ln(Density CC 1960)"
label var leadXdens "Lead x ln(Density CC 1960)"



reghdfe vc highLBXlead leadXhighway inter_rays_planc_1947 if cc==1 & nonmissACT==12, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 using table_vc_ccncc_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, YES, Missing, NO, Estimation, OLS)

reghdfe vc highLBXlead leadXdens_p5 inter_dens_cc_1960_p5  if cc==1 & nonmissACT==12, abs(fipsplace_00 year cdivcode#year) vce(cluster cdivcode#year)
outreg2 using table_vc_ccncc_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, YES, Missing, NO, Estimation, OLS)

gen vc_num= totn_ncc_offenses_vc if dup==0
replace vc_num=totn_cc_offenses_vc if dup==1
reghdfe vc_num cc leadXcc highLBXlead leadXccXhighLB , absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear fipsplace_00)
outreg2 using table_vc_ccncc_rob_ucrmeas, tex(frag) nocon noni nor2 nonotes label ctitle("Violent crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year, YES, Multi places, YES, Missing, YES, Estimation, OLS)


///////////////////////////////////////////////////////////////////////////////////////////
///Table A.45
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Generate other variables
gen pop_msa=tot_cc_oripop_corr+tot_ncc_oripop_corr
gen pop_msa_1960_2=pop_msa if year==1960
egen pop_msa_1960=max(pop_msa_1960_2) ,by(FMSA)
gen vc_pc=totnpcc_cc_offenses_vc*1000
g share_cc = cpop / pop
gen share_cc_1950_2=share_cc if year==1950
egen share_cc_1950=max(share_cc_1950_2), by(FMSA)
sum share_cc_1950, det
gen sub_1950=1 if share_cc_1950<=r(p25)
replace sub_1950=2 if share_cc_1950>r(p25) & share_cc_1950<=r(p50)
replace sub_1950=3 if share_cc_1950>r(p50) & share_cc_1950<=r(p75)
replace sub_1950=4 if share_cc_1950>r(p75)
replace sub_1950=. if share_cc_1950==.

*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Low LB x Lead"
label var inter_badtetra "High LB x Lead"

***Different FE
*No FE
ivreg perc_cc (vc_pc = inter_badtetra) , robust
outreg2 using table_rob_reg, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, NO, Year FE, NO, C. reg X Year FE, NO, C. div X Year FE, NO, State x Year FE, NO, Sub 1950 x Year FE, NO, Estimation, IV) replace
*Year FE
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(year) robust
local ff = trim("`: display %10.2f r(F)'")
outreg2 vc_pc using table_rob_reg, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, NO, Year FE, YES, C. reg X Year FE, NO, C. div X Year FE, NO, State x Year FE, NO, Sub 1950 x Year FE, NO, Estimation, IV, F, `ff') 
*Year+MSA FE
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_reg, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg X Year FE, NO, C. div X Year FE, NO, State x Year FE, NO, Sub 1950 x Year FE, NO, Estimation, IV, F, `ff') 
*Year+MSA+Region FE
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year cregcode#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_reg, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg X Year FE, YES, C. div X Year FE, NO, State x Year FE, NO, Sub 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Year+MSA+Division FE
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year cdivcode#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_reg, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg X Year FE, NO, C. div X Year FE, YES, State x Year FE, NO, Sub 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Year+MSA+State FE
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year STATEFP00#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_reg, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg X Year FE, NO, C. div X Year FE, NO, State x Year FE, YES, Sub 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Year+MSA+Subrb 1950 FE
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year sub_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_reg, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg X Year FE, NO, C. div X Year FE, NO, State x Year FE, NO, Sub 1950 x Year FE, YES, Estimation, IV, F, `ff')




///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.46
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Generate other variables
gen pop_msa=tot_cc_oripop_corr+tot_ncc_oripop_corr
gen pop_msa_1960_2=pop_msa if year==1960
egen pop_msa_1960=max(pop_msa_1960_2) ,by(FMSA)
gen vc_pc=totnpcc_cc_offenses_vc*1000
g share_cc = cpop / pop
gen share_cc_1950_2=share_cc if year==1950
egen share_cc_1950=max(share_cc_1950_2), by(FMSA)
sum share_cc_1950, det
gen sub_1950=1 if share_cc_1950<=r(p25)
replace sub_1950=2 if share_cc_1950>r(p25) & share_cc_1950<=r(p50)
replace sub_1950=3 if share_cc_1950>r(p50) & share_cc_1950<=r(p75)
replace sub_1950=4 if share_cc_1950>r(p75)
replace sub_1950=. if share_cc_1950==.

local varlist =  "empag empbus empcon empfire empman empmin emppro"
foreach var in `varlist'{
g `var'_rate = (`var' / pop) * 100
gen `var'_rate_1950_2=`var'_rate if year==1950
egen `var'_rate_1950=max(`var'_rate_1950_2), by(FMSA)
sum `var'_rate_1950, det
gen `var'_1950=1 if `var'_rate_1950<=r(p25)
replace `var'_1950=2 if `var'_rate_1950>r(p25) & `var'_rate_1950<=r(p50)
replace `var'_1950=3 if `var'_rate_1950>r(p50) & `var'_rate_1950<=r(p75)
replace `var'_1950=4 if `var'_rate_1950>r(p75)
replace `var'_1950=. if `var'_rate_1950==.
}

*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Low LB x Lead"
label var inter_badtetra "High LB x Lead"

***Different FE at economic level
*Year+MSA+Region FE
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year cregcode#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, YES, Agr 1950 x Year FE, NO, Bus 1950 x Year FE, NO, Constr 1950 x Year FE, NO, Fin 1950 x Year FE, NO, Manuf 1950 x Year FE, NO, Min 1950 x Year FE, NO, Prof 1950 x Year FE, NO, Estimation, IV, F, `ff') replace
*Agricultural trend
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year empag_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, NO, Agr 1950 x Year FE, YES, Bus 1950 x Year FE, NO, Constr 1950 x Year FE, NO, Fin 1950 x Year FE, NO, Manuf 1950 x Year FE, NO, Min 1950 x Year FE, NO, Prof 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Business trend
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year empbus_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, NO, Agr 1950 x Year FE, NO, Bus 1950 x Year FE, YES, Constr 1950 x Year FE, NO, Fin 1950 x Year FE, NO, Manuf 1950 x Year FE, NO, Min 1950 x Year FE, NO, Prof 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Construction trend
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year empcon_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, NO, Agr 1950 x Year FE, NO, Bus 1950 x Year FE, NO, Constr 1950 x Year FE, YES, Fin 1950 x Year FE, NO, Manuf 1950 x Year FE, NO, Min 1950 x Year FE, NO, Prof 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Finance trend
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year empfire_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, NO, Agr 1950 x Year FE, NO, Bus 1950 x Year FE, NO, Constr 1950 x Year FE, NO, Fin 1950 x Year FE, YES, Manuf 1950 x Year FE, NO, Min 1950 x Year FE, NO, Prof 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Manufacturing trend
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year empman_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, NO, Agr 1950 x Year FE, NO, Bus 1950 x Year FE, NO, Constr 1950 x Year FE, NO, Fin 1950 x Year FE, NO, Manuf 1950 x Year FE, YES, Min 1950 x Year FE, NO, Prof 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Mining trend
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year empmin_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, NO, Agr 1950 x Year FE, NO, Bus 1950 x Year FE, NO, Constr 1950 x Year FE, NO, Fin 1950 x Year FE, NO, Manuf 1950 x Year FE, NO, Min 1950 x Year FE, YES, Prof 1950 x Year FE, NO, Estimation, IV, F, `ff')
*Professional trend
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year emppro_1950#year) robust
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_ecofe, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Sh pop CC") addtext(MSA FE, YES, Year FE, YES, C. div X Year FE, NO, Agr 1950 x Year FE, NO, Bus 1950 x Year FE, NO, Constr 1950 x Year FE, NO, Fin 1950 x Year FE, NO, Manuf 1950 x Year FE, NO, Min 1950 x Year FE, NO, Prof 1950 x Year FE, YES, Estimation, IV, F, `ff')


///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.47
///////////////////////////////////////////////////////////////////////////////////////////

use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Generate other variables
gen pop_msa=tot_cc_oripop_corr+tot_ncc_oripop_corr
gen pop_msa_1960_2=pop_msa if year==1960
egen pop_msa_1960=max(pop_msa_1960_2) ,by(FMSA)
gen vc_pc=totnpcc_cc_offenses_vc*1000
egen cdivcodeyear=group(cdivcode year)

*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Low LB x Lead"
label var inter_badtetra "High LB x Lead"



egen dist=max(dis_borcoa), by(FMSA)
gen slope_pct=.
gen precip_pct=.
gen dist_pct=.
gen slope_pct0=0
gen precip_pct0=0
gen dist_pct0=0
forvalues i=10(10)90{
local j=`i'-10
egen slope_pct`i'=pctile(slope_plc_wtm_wtm_r), p(`i')
gen dummyslope_pct`i'=(slope_plc_wtm_wtm_r<=slope_pct`i' & slope_plc_wtm_wtm_r>slope_pct`j' & slope_plc_wtm_wtm_r!=.)
replace slope_pct=`i' if dummyslope_pct`i'==1
egen precip_pct`i'=pctile(precip_plc_wtm_wtm_r), p(`i')
gen dummyprecip_pct`i'=(precip_plc_wtm_wtm_r<=precip_pct`i' & precip_plc_wtm_wtm_r>precip_pct`j' & precip_plc_wtm_wtm_r!=.)
replace precip_pct=`i' if dummyprecip_pct`i'==1
egen dist_pct`i'=pctile(dist), p(`i')
gen dummydist_pct`i'=(dist<=dist_pct`i' & dist>dist_pct`j' & dist!=.)
replace dist_pct=`i' if dummydist_pct`i'==1
}
drop slope_pct0 precip_pct0 dist_pct0

ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_topo, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. division x Year FE, YES, Slope pctl X Year FE, NO, Precipitation pctl X Year FE, NO, Distance pctl X Year FE, NO, Estimation, IV, F, `ff') replace
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 slope_pct#year year cdivcode#year) cluster(cdivcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_topo, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. division x Year FE, YES, Slope pctl X Year FE, YES, Precipitation pctl X Year FE, NO, Distance pctl X Year FE, NO, Estimation, IV, F, `ff')
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 precip_pct#year year cdivcode#year) cluster(cdivcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_topo, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. division x Year FE, YES, Slope pctl X Year FE, NO, Precipitation pctl X Year FE, YES, Distance pctl X Year FE, NO, Estimation, IV, F, `ff')
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 dist_pct#year year cdivcode#year) cluster(cdivcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 vc_pc using table_rob_topo, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. division x Year FE, YES, Slope pctl X Year FE, NO, Precipitation pctl X Year FE, NO, Distance pctl X Year FE, YES, Estimation, IV, F, `ff')


///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.48
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Generate other variables
gen pop_msa=tot_cc_oripop_corr+tot_ncc_oripop_corr
gen pop_msa_1960_2=pop_msa if year==1960
egen pop_msa_1960=max(pop_msa_1960_2) ,by(FMSA)
gen vc_pc=totnpcc_cc_offenses_vc*1000
egen cdivcodeyear=group(cdivcode year)


*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Low LB x Lead"



ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2  using table_rob_pop, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, All, Weight, NO, Estimation, IV, F, `ff') replace
*Only cities more than 100000 people in 1960
ivreghdfe perc_cc (vc_pc = inter_badtetra) if pop_msa_1960>=100000, absorb(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 using table_rob_pop, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, More than 100000, Weight, NO, Estimation, IV, F, `ff')
*Weight by population MSA
ivreghdfe perc_cc (vc_pc = inter_badtetra) [aw=pop_msa], absorb(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 using table_rob_pop, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, All, Weight, Pop. MSA, Estimation, IV, F, `ff')
*Weight by population 1960
ivreghdfe perc_cc (vc_pc = inter_badtetra) [aw=pop_msa_1960], absorb(fipsplace_00 year cdivcode#year)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2 using table_rob_pop, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, All, Weight, Pop. MSA 1960, Estimation, IV, F, `ff')





///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.49
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Generate other variables
gen pop_msa=tot_cc_oripop_corr+tot_ncc_oripop_corr
gen pop_msa_1960_2=pop_msa if year==1960
egen pop_msa_1960=max(pop_msa_1960_2) ,by(FMSA)
gen vc_pc=totnpcc_cc_offenses_vc*1000
egen cdivcodeyear=group(cdivcode year)


*Label variables
label var vc_pc "Violent crime"
label var inter_badtetra "High LB x Lead"

reghdfe vc_pc inter_badtetra, absorb(fipsplace_00 year cdivcode#year)
outreg2  using table_rob_pop_fs, keep(inter_badtetra) tex(frag) nocon noni nonotes nor2 label ctitle("Violent Crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, All, Weight, NO, Estimation, OLS) replace
*Only cities more than 100000 people in 1960
reghdfe vc_pc  inter_badtetra if pop_msa_1960>=100000, absorb(fipsplace_00 year cdivcode#year)
outreg2 using table_rob_pop_fs, keep(inter_badtetra) tex(frag) nocon noni nonotes nor2 label ctitle("Violent Crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, More than 100000, Weight, NO, Estimation, OLS)
*Weight by population MSA
reghdfe vc_pc  inter_badtetra [aw=pop_msa], absorb(fipsplace_00 year cdivcode#year)
outreg2 using table_rob_pop_fs, keep(inter_badtetra) tex(frag) nocon noni nonotes nor2 label ctitle("Violent Crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, All, Weight, Pop. MSA, Estimation, OLS)
*Weight by population 1960
reghdfe vc_pc  inter_badtetra [aw=pop_msa_1960], absorb(fipsplace_00 year cdivcode#year)
outreg2 using table_rob_pop_fs, keep(inter_badtetra) tex(frag) nocon noni nonotes nor2 label ctitle("Violent Crime") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Sample, All, Weight, Pop. MSA 1960, Estimation, OLS)




///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.50
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear
drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Generate other variables
gen pop_msa=tot_cc_oripop_corr+tot_ncc_oripop_corr
gen pop_msa_1960_2=pop_msa if year==1960
egen pop_msa_1960=max(pop_msa_1960_2) ,by(FMSA)
gen vc_pc=totnpcc_cc_offenses_vc*1000
egen cregcodeyear=group(cregcode year)


*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Low LB x Lead"

*All years
ivreghdfe perc_cc (vc_pc = inter_badtetra), absorb(fipsplace_00 year cregcode#year) cluster(cregcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2  using table_rob_year, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg x Year, YES, Year, 60-91, Estimation, IV, F, `ff') replace
*Census years
ivreghdfe perc_cc (vc_pc = inter_badtetra) if year==1960 | year==1970 | year==1980 | year==1990, absorb(fipsplace_00 year cregcode#year) cluster(cregcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2  using table_rob_year, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg x Year, YES, Year, 1960 1970 1980 1990, Estimation, IV, F, `ff')
*1960-1990
ivreghdfe perc_cc (vc_pc = inter_badtetra) if year==1960 | year==1990, absorb(fipsplace_00 year cregcode#year) cluster(cregcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2  using table_rob_year, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg x Year, YES, Year, 1960 1990, Estimation, IV, F, `ff')
*1960-1979
ivreghdfe perc_cc (vc_pc = inter_badtetra) if year<=1980, absorb(fipsplace_00 year cregcode#year) cluster(cregcodeyear)
local ff = trim("`: display %10.2f e(cdf)'")
outreg2  using table_rob_year, keep(vc_pc) tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. reg x Year, YES, Year, 1960-1979, Estimation, IV, F, `ff')



///////////////////////////////////////////////////////////////////////////////////////////
///Table A.51
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear
drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
g bad_soil = 1-good_soil
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Generate other variables
gen pop_msa=tot_cc_oripop_corr+tot_ncc_oripop_corr
gen pop_msa_1960_2=pop_msa if year==1960
egen pop_msa_1960=max(pop_msa_1960_2) ,by(FMSA)
gen vc_pc=totnpcc_cc_offenses_vc*1000
egen cregcodeyear=group(cregcode year)
egen cdivcodeyear=group(cdivcode year)

drop pop_ccr pop_nccr pop_msa_1960_2 pop_msa_1960
rename tot_cc_oripop_corr pop_cc
rename tot_ncc_oripop_corr pop_ncc

foreach var of varlist vc_pc perc_cc pop_cc pop_ncc pop_msa{
	foreach y in "1960" "1970" "1980" "1991"{
		gen `var'_`y'_2=`var' if year==`y'
		egen `var'_`y'=max(`var'_`y'_2), by(FMSA)
		drop `var'_`y'_2
		gen ln`var'_`y'=ln(`var'_`y')
	}
	foreach w in "1970" "1980" "1991"{
		gen `var'_diff_1960`w'=`var'_`w'-`var'_1960
		gen ln`var'_diff_1960`w'=ln`var'_`w'-ln`var'_1960
	}
}


*Label variables
label var vc_pc_diff_19601991 "D. Violent crime"
label var bad_soil "High LB"
label var perc_cc_diff_19601991 "D. Sh. Pop CC"
label var lnpop_cc_diff_19601991 "D. ln(Pop CC)"
label var lnpop_ncc_diff_19601991 "D. ln(Pop NCC)"
label var lnpop_msa_diff_19601991 "D. ln(Pop MSA)"

qui ivreghdfe perc_cc_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cdivcode) robust
keep if e(sample)

***Census division FE
*First stage
reghdfe vc_pc_diff_19601991 bad_soil if year==1991, absorb(cdivcode) vce(robust)
est sto cdiv1
estadd local estim "OLS" , replace
estadd local ff ".", replace
*OLS
reghdfe perc_cc_diff_19601991 vc_pc_diff_19601991 if year==1991, absorb(cdivcode) vce(robust)
est sto cdiv2
estadd local estim "OLS" , replace
estadd local ff ".", replace
*IV perc_cc
ivreghdfe perc_cc_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cdivcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto cdiv3  
estadd local estim "IV" , replace
estadd local ff "`ff'", replace
*RF
reghdfe perc_cc_diff_19601991 bad_soil if year==1991, absorb(cdivcode) vce(robust)
est sto cdiv4
estadd local estim "OLS" , replace
estadd local ff ".", replace
*IV pop_cc
ivreghdfe lnpop_cc_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cdivcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto cdiv5
estadd local estim "IV" , replace
estadd local ff "`ff'", replace
*IV pop_ncc
ivreghdfe lnpop_ncc_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cdivcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto cdiv6
estadd local estim "IV" , replace
estadd local ff "`ff'", replace
*IV pop_msa
ivreghdfe lnpop_msa_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cdivcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto cdiv7
estadd local estim "IV" , replace
estadd local ff "`ff'", replace

***Census region FE
*First stage
reghdfe vc_pc_diff_19601991 bad_soil if year==1991, absorb(cregcode) vce(robust)
est sto creg1
estadd local estim "OLS" , replace
estadd local ff ".", replace
*OLS
reghdfe perc_cc_diff_19601991 vc_pc_diff_19601991 if year==1991, absorb(cregcode) vce(robust)
est sto creg2
estadd local estim "OLS" , replace
estadd local ff ".", replace
*IV perc_cc
ivreghdfe perc_cc_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cregcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto creg3 
estadd local estim "IV" , replace
estadd local ff "`ff'", replace
*RF
reghdfe perc_cc_diff_19601991 bad_soil if year==1991, absorb(cregcode) vce(robust)
est sto creg4
estadd local estim "OLS" , replace
estadd local ff ".", replace
*IV pop_cc
ivreghdfe lnpop_cc_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cregcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto creg5
estadd local estim "IV" , replace
estadd local ff "`ff'", replace
*IV pop_ncc
ivreghdfe lnpop_ncc_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cregcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto creg6 
estadd local estim "IV" , replace
estadd local ff "`ff'", replace
*IV pop_msa
ivreghdfe lnpop_msa_diff_19601991 (vc_pc_diff_19601991 = bad_soil) if year==1991, absorb(cregcode) robust
local ff= string(round(e(cdf),.01) , "%9.2f")
est sto creg7
estadd local estim "IV" , replace
estadd local ff "`ff'", replace

esttab cdiv1 cdiv2 cdiv3 cdiv4 cdiv5 cdiv6 cdiv7 using table_baseline_longdiff.tex, ///
	   prehead("\begin{tabular}{l*{7}{c}} \hline\hline") ///
	   posthead("\hline \\ \multicolumn{8}{c}{Panel A: Census division FE. Difference 1991-60} \\\\[-1ex]") ///
	   fragment label nocon noobs se ///
	   s(N estim ff, label("Observations" "Estimation" "F")) ///
	   star(* 0.10 ** 0.05 *** 0.01) replace
	   
esttab creg1 creg2 creg3 creg4 creg5 creg6 creg7 using table_baseline_longdiff.tex, ///
	   posthead("\hline \\ \multicolumn{8}{c}{Panel B: Census region FE. Difference 1991-60} \\\\[-1ex]") ///
	   fragment append nomtitles nonumbers ///
	   nolines s(N estim ff, label("Observations" "Estimation" "F")) ///
	   star(* 0.10 ** 0.05 *** 0.01) ///
	   prefoot("\hline") ///
	   postfoot("\hline\hline \end{tabular}") ///
	   label nocon se 



///////////////////////////////////////////////////////////////////
///FIGURE A.22
///////////////////////////////////////////////////////////////////

///First-stage
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g pop_msa = tot_ncc_oripop_corr + tot_cc_oripop_corr

*Create dependent variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
g lnpop_cc = ln(tot_cc_oripop_corr)
g lnpop_ncc = ln(tot_ncc_oripop_corr)
gen lnpop_msa=ln(pop_msa)

*Cluster variables
egen cdivcodeyear=group(cdivcode year)

*Label variables
label var vc_pc "Violent crime"
label var inter_badtetra "High LB x Lead"

mat XX = J(325,1,1)*9999

qui:{
	levelsof fipsplace_00, local(levels) 
	local i = 0
	foreach l of local levels {
		local i = `i' + 1
		reghdfe vc_pc inter_badtetra if fipsplace_00 != `l', abs(fipsplace_00 year cdivcode#year) 
		mat XX[`i',1] = _b[inter_badtetra]
	}
}

g plbetas = XX[_n,1] in 1/325

reghdfe vc_pc inter_badtetra, abs(fipsplace_00 year cdivcode#year)
local full_eff = _b[inter_badtetra]

twoway (hist plbetas,  xlabel(3(0.1)3.6) frac xtitle("Leave-one-out estimates", size(large))) (scatteri 0 `full_eff' .7 `full_eff', lw(1.2) c(l) m(i) legend(label(2 "First-stage estimate"))) 
graph export leave_first.png, as(png) replace

///////////Second-stage
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
g pop_msa = tot_ncc_oripop_corr + tot_cc_oripop_corr

*Create dependent variables
gen vc_pc=totnpcc_cc_offenses_vc*1000
g lnpop_cc = ln(tot_cc_oripop_corr)
g lnpop_ncc = ln(tot_ncc_oripop_corr)
gen lnpop_msa=ln(pop_msa)

*Cluster variables
egen cdivcodeyear=group(cdivcode year)

*Label variables
label var vc_pc "Violent crime"
label var inter_badtetra "High LB x Lead"

mat XX = J(325,1,1)*9999

qui:{
	levelsof fipsplace_00, local(levels) 
	local i = 0
	foreach l of local levels {
		local i = `i' + 1
		ivreghdfe perc_cc (vc_pc = inter_badtetra)  if fipsplace_00 != `l', abs(fipsplace_00 year cdivcode#year)
		mat XX[`i',1] = _b[vc_pc]
		noisily: di `i'
	}
}

g plbetas = XX[_n,1] in 1/325

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) 
local full_eff = _b[vc_pc]

twoway (hist plbetas,  w(0.0005) start(-0.02) xlabel(-0.02(0.0025)-0.01) frac xtitle("Leave-one-out estimates", size(large))) (scatteri 0 `full_eff' .8 `full_eff', lw(1.2) c(l) m(i) legend(label(2 "Second-stage estimate"))) 
graph export leave_second.png, as(png) replace






///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.52
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Create standardized variables
egen sd_vc=sd(totnpcc_cc_offenses_vc)
gen standardized_vc=totnpcc_cc_offenses_vc/sd_vc

*Generate other variables
egen placeyear=group(fipsplace_00 year)
egen cregcodeyear=group(cregcode year)
egen cdivcodeyear=group(cdivcode year)
egen stateyear=group(STATEFP00 year)
gen vc_pc=totnpcc_cc_offenses_vc*1000


*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Low LB x Lead"

***Cluster s.e.
ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) robust
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, NO, F, `ff') replace

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(year)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, Year, F, `ff')

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(fipsplace_00)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, Place, F, `ff')

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(placeyear)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, Place-year, F, `ff')

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(cregcodeyear)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, C. reg-year, F, `ff')

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, C. div-year, F, `ff')

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(stateyear)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, State-year, F, `ff')


///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.53
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)

*Create standardized variables
egen sd_vc=sd(totnpcc_cc_offenses_vc)
gen standardized_vc=totnpcc_cc_offenses_vc/sd_vc

*Generate other variables
egen placeyear=group(fipsplace_00 year)
egen cregcodeyear=group(cregcode year)
egen cdivcodeyear=group(cdivcode year)
egen stateyear=group(STATEFP00 year)
gen vc_pc=totnpcc_cc_offenses_vc*1000


*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Low LB x Lead"

g decade = floor((year - 1900) / 10)
replace decade = 8 if year == 1990 | year==1991

g sep = "-"



g five = floor((year - 1900) / 5)
*replace decade = 8 if year == 1990 | year==1991



egen C_DEC = concat(cdivcode sep decade)
encode C_DEC,g(cdivXdecade)

egen R_DEC = concat(cregcode sep decade)
encode R_DEC,g(cregXdecade)

egen S_DEC = concat(STATEFP00 sep decade)
encode S_DEC,g(stateXdecade)



egen C_FIVE = concat(cdivcode sep five)
encode C_FIVE,g(cdivXfive)

egen R_FIVE = concat(cregcode  sep five)
encode R_FIVE,g(cregXfive)

egen S_FIVE = concat(STATEFP00  sep five)
encode S_FIVE,g(stateXfive)

***Cluster s.e.
ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(cregXdecade)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se2, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, C. Reg-Decade, F, `ff') replace
sleep 700

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(cregXfive)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se2, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, C. Reg-5 year, F, `ff')
sleep 700

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(cdivXdecade)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se2, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, C. Div-Decade, F, `ff') 
sleep 700

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(cdivXfive)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se2, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, C. Div-5 year, F, `ff')
sleep 700

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(stateXdecade)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se2, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, State-Decade, F, `ff')
sleep 700

ivreghdfe perc_cc (vc_pc = inter_badtetra), abs(fipsplace_00 year cdivcode#year) cluster(stateXfive)
local ff = trim("`: display %10.2f  e(rkf)'")
outreg2 vc_pc using table_rob_se2, tex(frag) nocon noni nonotes nor2 label ctitle("Share pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, Estimation, IV, s.e. cluster, State-5 year, F, `ff')





///////////////////////////////////////////////////////////////////////////////////////////
///TABLE A.54
///////////////////////////////////////////////////////////////////////////////////////////
use "finaldata\final_cc_data.dta", clear

drop if fipsplace_00==.
xtset fipsplace_00 year

drop if year>1991

***Merge with employment decentralization
merge 1:1 fipsplace_00 year using "finaldata\data_cbp.dta"

drop if fipsplace_00==.
xtset fipsplace_00 year

*Create instrument and outcome
g good_soil = (ph1_plc_wtm_wtm_0_r>=6.8 & ph1_plc_wtm_wtm_0_r<=7.7)
gen inter_goodtetra=good_soil*tetra_corr
gen inter_badtetra=(1-good_soil)*tetra_corr
g perc_cc =  tot_cc_oripop_corr / (tot_ncc_oripop_corr + tot_cc_oripop_corr)
gen vc_pc=totnpcc_cc_offenses_vc*1000

*Generate other variables
gen l10perc_cc=L10.perc_cc 
gen l10perc_empl_ctycc_sic0= L10.perc_empl_ctycc_sic0
gen l10perc_empl_ctycc_sic20= L10.perc_empl_ctycc_sic20

*Time trends
gen cdivcodeyear=cdivcode*year

*Label variables
label var vc_pc "Violent crime"
label var inter_goodtetra "Good soil x Lead"
label var good_soil "Good soil"
label var l10perc_cc "Share Pop CC (10 years lag)"
label var l10perc_empl_ctycc_sic0  "Share Empl CC (10 years lag)"
label var l10perc_empl_ctycc_sic20  "Share Manuf CC (10 years lag)"

***Regressions (long)
ivreghdfe perc_empl_ctycc_sic20 (vc_pc=inter_badtetra),  absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_rob_timingdec, tex(frag) nocon noni nor2 nonotes label ctitle("Share Manuf CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, High LB x Lead 29 years lag, NO, Estimation, IV, F, `ff')  replace
ivreghdfe perc_empl_ctycc_sic20 l10perc_cc L10.inter_badtetra (vc_pc=inter_badtetra),  absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc l10perc_cc using table_rob_timingdec, tex(frag) nocon noni nor2 nonotes label keep(vc_pc l10perc_cc) ctitle("Share Manuf CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, High LB x Lead 29 years lag, YES, Estimation, IV, F, `ff')

ivreghdfe perc_cc (vc_pc=inter_badtetra) if year>=1974,  absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc using table_rob_timingdec, tex(frag) nocon noni nor2 nonotes label ctitle("Share Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, High LB x Lead 29 years lag, NO, Estimation, IV, F, `ff')
ivreghdfe perc_cc l10perc_empl_ctycc_sic20 L10.inter_badtetra (vc_pc=inter_badtetra),  absorb(fipsplace_00 year cdivcode#year) cluster(cdivcodeyear)
local ff= string(round(e(cdf),.01) , "%9.2f")
outreg2 vc_pc l10perc_empl_ctycc_sic20 using table_rob_timingdec, tex(frag) nocon noni nor2 nonotes label keep(vc_pc l10perc_empl_ctycc_sic20) ctitle("Share Pop CC") addtext(MSA FE, YES, Year FE, YES, C. div x Year FE, YES, High LB x Lead 29 years lag, YES, Estimation, IV, F, `ff')
